package com.zxy.fmmall.config;

import com.zxy.fmmall.interceptor.CheckToKenInterceptor;
import com.zxy.fmmall.interceptor.SetTimeInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private CheckToKenInterceptor checkToKenInterceptor;
    @Autowired
    private SetTimeInterceptor setTimeInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(checkToKenInterceptor)
                .addPathPatterns("/shopcart/**")
                .addPathPatterns("/userAddr/**")
                .addPathPatterns("/orders/**")
                .excludePathPatterns("/user/**")
                .addPathPatterns("/user/check/**");

        registry.addInterceptor(setTimeInterceptor)
                .addPathPatterns("/**").excludePathPatterns("/user/login");
    }
}
